<?php
	require_once('../../config/config.php');

	class registration extends parser
	{
		public function isCVUploaded()
		{
			if (isset($_FILES['cv']) && count($_FILES) > 0)
			{
				$cv = $_FILES['cv'];
				if ($cv['error'] == 0)
				{
					$valid_types = explode(",", VALID_FORMATS);
					
					if (in_array($cv['type'], $valid_types))
					{
						if (!is_dir(TMP_DOCUMENT_PATH))
							mkdir(TMP_DOCUMENT_PATH);
						
						move_uploaded_file($cv['tmp_name'], TMP_DOCUMENT_PATH . $cv['name']);
						
						$this->current_file_name = $cv['name'];
						$this->current_file_ext = end(explode('.', $this->current_file_name));
						$this->current_file_path = TMP_DOCUMENT_PATH;
						
						$this->parseText();
						$this->getEmailFromData();
						
						return true;
					}
					else
					{
						$_SESSION['error'] = 'Please upload the valid file.';
						header('Location: ' . SITE_URL);
					}
					
				}
				else
				{
					$_SESSION['error'] = 'You must have to upload the valid file.';
					header('Location: ' . SITE_URL);
				}
			}
			header('Location: ' . SITE_URL);
		}		
	}
	
	require_once(APP_PATH . 'registration.php');
?>